1. Field of the Invention
The present invention relates to an apparatus for decoding a bit stream of image data compressed using the MPEG (Moving Picture Experts Group) format, in particular, to an apparatus which detects a start code at the head of each data included in the bit stream.
2. Description of the Related Art
Each bit stream in the MPEG format has a 6-layer structure; thus, the layer to which each data (included in the bit stream) belongs must be determined, and a specific code called the start code is assigned to each layer of the bit stream.
In each bit stream, any portion other than the start code does not have the same bit pattern as that of the start code. In addition, in the MPEG standard, the start code should start from the first bit of a byte in the bit stream, that is, the first bit of the start code should be positioned at the first bit of a byte. In this case, the start code can be detected by searching each byte of the bit stream.
FIG. 5 shows an example of conventional MPEG image decoding apparatuses. Each bit stream including serial data is input into this MPEG image decoding apparatus, and is stored in a buffer 101. Each bit stream stored in the buffer 101 is read out in the storage order (i.e. FIFO (first-in first-out)), and transferred to a register 102. A byte search section 103 searches the data stored in the register 102 to detect a start code for indicating the starting point of each data. In order to search the data in the register 102 to find the start code, the byte search section 103 collates byte-unit data (i.e., the position for collation in the data is shifted by an integer multiple of a byte) with predetermined data for collation because in the MPEG standard, the start code should start from the first bit of a byte, as explained above.
When the byte search section 103 detects a start code from among the data stored in the register 102, the byte search section communicates the position (i.e., address) of the start code in the data (stored in the register 102) to a shifter 104. The shifter 104 determines the position of the start code in the data transferred from the register 102, by referring to the address communicated by the byte search section 103. The shifter 104 sends xe2x80x9cretrieved dataxe2x80x9d to a decoder 105, where the retrieved data starts from an already-detected start code and ends immediately before the next start code which has also been detected, and thus the retrieved data includes a start code and data related to the start code. The decoder 105 decodes the retrieved data sent from the shifter 104.
On the other hand, the data from the above next start code in the shifter 104 is shifted towards the head to occupy the area which has been occupied by the retrieved data, and the shifted data is returned to the register 102 as xe2x80x9cnon-retrieved dataxe2x80x9d. In the register 102, the empty area provided after the non-retrieved data is filled with next data from buffer 101. The byte search section 103 then searches for the next start code.
As explained above, in each bit stream, the head of the start code should be positioned at the head of a byte based on the MPEG standard, and in the conventional MPEG image decoding apparatus, each start code in the bit stream is searched for in byte units.
However, the above-explained conventional technique has the following problem: If an unnecessary bit is inserted or if a necessary bit is omitted in a bit stream for any reason, the head of the start code is shifted from the first bit of a relevant byte. In this case, the start code cannot be detected in the above conventional technique, and normal images cannot be shown on a display.
In consideration of the above circumstances, an objective of the present invention is to provide an MPEG image decoding apparatus and method for supplying normal images even if an unnecessary bit is inserted or a necessary bit is omitted in a bit stream (i.e., a nonstandardized bit stream) and thus the bit stream has an error.
Therefore, the present invention provides an MPEG image decoding apparatus comprising:
a buffer for receiving a bit stream which has been compressed based on the MPEG format, and temporarily storing data of the bit stream and outputting the stored data in input order;
a register for receiving the data output from the buffer and storing the data in an empty area of the register in turn;
a first data-search section for:
searching the data stored in the register so as to detect the position of a specific code by executing a byte-unit data collating operation in which the collated position in the data is shifted by an integer multiple of a byte; and
outputting a search result;
a second data-search section for:
searching the data stored in the register so as to detect the position of a specific code by executing a bit-unit data collating operation in which the collated position in the data is shifted by an integer multiple of a bit; and
outputting a search result;
a search operation control section for choosing one of an output from the first data-search section and an output from the second data-search section;
a shifter for extracting a retrieved data from among the data stored in the register based on the output chosen by the search operation control section, and shifting the remaining non-retrieved data towards the head of the register and making an empty area after the non-retrieved data in the register; and
a decoding section for decoding the retrieved data extracted by the shifter.
Typically, the specific code which is searched for by the first and second data-search sections is a start code positioned at the head of each specific data included in the bit stream.
Typically, the search operation control section first chooses the output from the first data-search section, and if the first data-search section did not detect the specific code, then the search operation control section chooses the output from the second data-search section.
More specifically, the search operation control section may choose the output from the second data-search section:
(i) if the first data-search section searched all the data in the register and did not detect the specific code;
(ii) if the first data-search section did not detect the specific code during a predetermined time;
(iii) if the first data-search section processed a predetermined amount of data in the data collating operation and did not detect the specific code;
(iv) if the total amount of shifts of the collated data position in the data collating operation of the first data-search section exceeds a predetermined limit value; or
(v) if the search operation control section detects the amount of bit errors in the bit stream, and the amount of bit errors exceeds a predetermined limit value.
The buffer, the register, the first data-search section, the second data-search section, the search operation control section, the shifter, and the decoding section may be formed on a semiconductor integrated circuit substrate.
The present invention also provides an MPEG image decoding method comprising:
a temporary storage step of receiving a bit stream which has been compressed based on the MPEG format, and temporarily storing data of the bit stream and outputting the stored data in input order;
a register storage step of receiving the data output in the temporary storage step and storing the data in an empty area of a register in turn;
a first data-search step of:
searching the data stored in the register so as to detect the position of a specific code by executing a byte-unit data collating operation in which the collated position in the data is shifted by an integer multiple of a byte; and
outputting a search result;
a second data-search step of:
searching the data stored in the register so as to detect the position of a specific code by executing a bit-unit data collating operation in which the collated position in the data is shifted by an integer multiple of a bit; and
outputting a search result;
an output choosing step of choosing one of an output in the first data-search step and an output in the second data-search step;
a shift step of extracting a retrieved data from among the data stored in the register based on the output chosen in the output choosing step, and shifting the remaining non-retrieved data towards the head of the register and making an empty area after the non-retrieved data in the register; and
a decoding step of decoding the retrieved data extracted in the shift step.
Typically, the specific code searched for in the first and second data-search steps is a start code positioned at the head of each specific data included in the bit stream.
According to the present invention, in the search for a specific code (typically, the start code) in the bit stream compressed based in the MPEG format, a dynamic switching of the search method is possible, and the specific code can be reliably detected. That is, even if unnecessary data is inserted or necessary data is omitted in the bit stream, the start code can be detected. Therefore, each start code in the start code can be reliably detected and images can be smoothly reproduced.